<!doctype html>
<title>Use files after the origin has been removed through quota</title>
<script>
  let test_file;

  async function openFile() {
    if (storageFoundation) {
      test_file = await storageFoundation.open('test_file');
      return await test_file.getLength() == 0;
    } else {
      return false;
    }
  }

  async function tryAccessOpenedFile() {
    try {
      await test_file.getLength();
    } catch (e) {
      return e.name;
    }
    return '';
  }

  async function openAnotherFile() {
    if (storageFoundation) {
      let another_file = await storageFoundation.open('another_file');
      return await another_file.getLength() == 0;
    } else {
      return false;
    }
  }

  function countFiles() {
    return storageFoundation.getAll().then(files => { return files.length; });
  }
</script>
